﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entity.Framework;

namespace Business.Operations
{
    public class MahalleOperation
    {
        private static HPDMASEntities db = new HPDMASEntities();

        public MahalleOperation()
        {

        }

        public static List<Mahalle> MahalleGetAll()
        {
            var mahalleListesi = db.Mahalle.ToList();
            return mahalleListesi;
        }

        public static Mahalle MahalleGetByMahalleId(int mahalleId)
        {
            var mahalle = (from c in db.Mahalle where c.MahalleID == mahalleId select c).First();
            return mahalle;
        }

        public static Mahalle MahalleGetByIlceId(string ilceId)
        {
            var m = (from c in db.Mahalle where c.IlceID == ilceId select c).First();
            return m;
        }

        /// <summary>
        /// Diger Fonksiyonlar
        /// </summary>
        /// <returns></returns>
        public static List<string> MahalleAdiGetAll()
        {
            var mahalleColumn = from s in db.Mahalle select s.MahalleAdi;
            List<string> mahalleList = mahalleColumn.ToList();
            return mahalleList;
        }

        public static List<string> MahalleAdiGetByIlceId(string ilceId)
        {
            var m = (from k in db.Mahalle where k.IlceID == ilceId select k.MahalleAdi);
            List<string> mList = m.ToList();
            return mList;
        }

        public static string MahalleAdiGetByKullaniciId(int kullaniciId)
        {
            var m = (from k in db.KullaniciNfs where k.KullaniciID == kullaniciId select k.Mahalle.MahalleAdi).First();
            return m;
        }

        public static int MahalleIdGetByMahalleAdiAndIlceIdAndSehirId(string mahalleAdi, string ilceId, string sehirId)
        {
            var m = (from c in db.Mahalle where c.MahalleAdi== mahalleAdi && c.IlceID==ilceId && c.SehirID == sehirId select c.MahalleID).First();
            return m;
        }
    }
}
